using System;
using System.Data;
using System.Linq;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using DataObject.Model;
using DataObject.Database;

public partial class RouteMapper
{
    #region ToSingle

    public static RouteDTO ToSingle(Route entity)
    {
        if (entity == null)
        {
            return null;
        }
        return new RouteDTO
        {
            Active = entity.Active,
            Description = entity.Description,
            ModifiedBy = entity.ModifiedBy,
            ModifiedDate = entity.ModifiedDate,
            RouteID = entity.RouteID,
            RouteName = entity.RouteName,
            RouteNumber = entity.RouteNumber,
            SubRouteCode = entity.SubRouteCode,
            NumOfMeals = entity.NumOfMeals,
            HasShuttle = entity.HasShuttle,
            HasFlight = entity.HasFlight,
            ProviderName = entity.ProviderName
        };
    }

    #endregion

    #region ToEntity

    public static Route ToEntity(Route entity, RouteDTO businessobject)
    {
        if (businessobject == null)
        {
            return null;
        }
        entity.Active = businessobject.Active;
        entity.Description = businessobject.Description;
        entity.ModifiedBy = businessobject.ModifiedBy;
        entity.ModifiedDate = businessobject.ModifiedDate;
        entity.RouteID = businessobject.RouteID;
        entity.RouteName = businessobject.RouteName;
        entity.RouteNumber = businessobject.RouteNumber;
        entity.SubRouteCode = businessobject.SubRouteCode;
        entity.NumOfMeals = businessobject.NumOfMeals;
        entity.HasShuttle = businessobject.HasShuttle;
        entity.HasFlight = businessobject.HasFlight;
        entity.ProviderName = businessobject.ProviderName;
        return entity;
    }

    #endregion

    #region ToBusinessObject

    public static RouteDTO ToBusinessObject(Route entity)
    {
        if (entity == null)
        {
            return null;
        }
        return new RouteDTO
        {
            Active = entity.Active,
            Description = entity.Description,
            ModifiedBy = entity.ModifiedBy,
            ModifiedDate = entity.ModifiedDate,
            RouteID = entity.RouteID,
            RouteName = entity.RouteName,
            RouteNumber = entity.RouteNumber,
            SubRouteCode = entity.SubRouteCode,
            NumOfMeals = entity.NumOfMeals,
            HasShuttle = entity.HasShuttle,
            HasFlight = entity.HasFlight,
            ProviderName = entity.ProviderName
        };
    }

    #endregion

    #region ToBusinessObjectHasChildren

    public static RouteDTO ToBusinessObjectHasChildren(Route entity, params Type[] types)
    {
        if (entity == null)
        {
            return null;
        }
        RouteDTO businessobject = new RouteDTO
        {
            Active = entity.Active,
            Description = entity.Description,
            ModifiedBy = entity.ModifiedBy,
            ModifiedDate = entity.ModifiedDate,
            RouteID = entity.RouteID,
            RouteName = entity.RouteName,
            RouteNumber = entity.RouteNumber,
            SubRouteCode = entity.SubRouteCode,
            NumOfMeals = entity.NumOfMeals,
            HasShuttle = entity.HasShuttle,
            HasFlight = entity.HasFlight,
            ProviderName = entity.ProviderName
        };
        if (types.Contains<Type>(typeof(RouteService)) || types.Length == 0)
        {
            businessobject.RouteServiceCollection = new List<RouteServiceDTO>();
            foreach (var item in entity.RouteServices)
            {
                businessobject.RouteServiceCollection.Add(RouteServiceMapper.ToBusinessObject(item));
            }
        }
        return businessobject;
    }

    #endregion

}